<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="Admin_UserPermission.aspx.cs" Inherits="Admin_UserPermission" Title="Tackle - Administer User Permissions" %>

<%@ PreviousPageType VirtualPath="~/Admin_Users.aspx" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentHolder" runat="Server">
    <strong>Administer User Permissions<br />
        <br />
    </strong><span style="font-size: 8pt">This page allows the management of permissions
        for a user.<br />
        <br />
    </span>
    <asp:UpdatePanel runat="server" ID="UPGridView" UpdateMode="Conditional">
        <ContentTemplate>
            <table width="98%" cellpadding="4" cellspacing="0">
                <tr>
                    <td bgcolor="#e3eaeb" style="border-right: silver 1px ridge; border-top: silver 1px ridge;
                        border-left: silver 1px ridge; border-bottom: silver 1px ridge">
                        <span style="font-size: x-small">Page size:</span><strong> </strong>
                        <asp:DropDownList ID="dlPageSize" runat="server" AutoPostBack="True" Font-Names="Verdana"
                            Font-Size="X-Small" OnSelectedIndexChanged="dlPageSize_SelectedIndexChanged">
                            <asp:ListItem>10</asp:ListItem>
                            <asp:ListItem>25</asp:ListItem>
                            <asp:ListItem>50</asp:ListItem>
                            <asp:ListItem>100</asp:ListItem>
                            <asp:ListItem>All</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr bgcolor="#e3eaeb">
                    <td>
                        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="X-Small"
                            Text="User:"></asp:Label>
                        <asp:Label ID="lblUserName" runat="server" Font-Italic="False" Font-Names="Verdana"
                            Font-Size="X-Small" Text="Label"></asp:Label><br />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:GridView ID="gvUserPermissions" runat="server" DataSourceID="dsUserPermission"
                            CellPadding="4" Font-Names="Verdana" Font-Size="X-Small" ForeColor="#333333"
                            GridLines="None" AutoGenerateColumns="False" DataKeyNames="UserPermissionID"
                            AllowPaging="True" AllowSorting="True">
                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#E3EAEB" />
                            <EditRowStyle BackColor="#7C6F57" />
                            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <AlternatingRowStyle BackColor="White" />
                            <Columns>
                                <asp:TemplateField HeaderText="Scrum Team" SortExpression="ScrumTeamName">
                                    <EditItemTemplate>
                                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="sdScrumTeam" DataTextField="ScrumTeamName"
                                            DataValueField="ScrumTeamID" Font-Names="Verdana" Font-Size="X-Small" SelectedValue='<%# Bind("fScrumTeamID") %>'>
                                        </asp:DropDownList><asp:SqlDataSource ID="sdScrumTeam" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
                                            SelectCommand="SELECT [ScrumTeamName], [ScrumTeamID] FROM [tblScrumTeam] ORDER BY ScrumTeamName">
                                        </asp:SqlDataSource>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("ScrumTeamName") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Permission" SortExpression="Description">
                                    <EditItemTemplate>
                                        &nbsp;<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="dsPermission"
                                            DataTextField="Description" DataValueField="PermissionID" Font-Names="Verdana"
                                            Font-Size="X-Small" SelectedValue='<%# Bind("PermissionLevel") %>'>
                                        </asp:DropDownList><asp:SqlDataSource ID="dsPermission" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
                                            SelectCommand="SELECT [PermissionID], [Description] FROM [tblPermissions]"></asp:SqlDataSource>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:CommandField ShowEditButton="True" />
                                <asp:TemplateField ShowHeader="False">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDeleteRecord" runat="server" BorderColor="Black" CausesValidation="False"
                                            CommandName="Delete" ForeColor="Black" OnClientClick="return confirm('Are you sure you want to delete this record?');"
                                            Text="Delete"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <asp:SqlDataSource ID="dsUserPermission" runat="server" ConnectionString="<%$ ConnectionStrings:TackleConnectionStringMain %>"
                            ProviderName="<%$ ConnectionStrings:TackleConnectionStringMain.ProviderName %>"
                            SelectCommand="SELECT tblUserPermissions.UserPermissionID, tblUserPermissions.PermissionLevel, tblUserPermissions.fScrumTeamID, tblUserPermissions.fUserID, tblUsers.UserName, tblPermissions.Description, tblScrumTeam.ScrumTeamName FROM tblUserPermissions INNER JOIN tblUsers ON tblUserPermissions.fUserID = tblUsers.UserID INNER JOIN tblPermissions ON tblUserPermissions.PermissionLevel = tblPermissions.PermissionID INNER JOIN tblScrumTeam ON tblUserPermissions.fScrumTeamID = tblScrumTeam.ScrumTeamID WHERE (tblUserPermissions.fUserID = @UserID)&#13;&#10;ORDER BY tblScrumTeam.ScrumTeamName , tblUserPermissions.PermissionLevel"
                            OnSelecting="dsUserPermission_Selecting" UpdateCommand="UPDATE tblUserPermissions SET fScrumTeamID = @fScrumTeamID, PermissionLevel = @PermissionLevel WHERE (UserPermissionID = @original_UserPermissionID)"
                            OldValuesParameterFormatString="original_{0}" OnUpdating="dsUserPermission_Updating"
                            DeleteCommand="DELETE FROM tblUserPermissions WHERE (UserPermissionID = @original_UserPermissionID)">
                            <SelectParameters>
                                <asp:Parameter Name="UserID" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                    </td>
                    <tr>
                        <td>
                            <asp:Button ID="btnNewPermission" runat="server" Font-Names="Verdana" Font-Size="X-Small"
                                Text="New Permission" OnClick="btnNewPermission_Click" />
                        </td>
                    </tr>
                <tr>
                    <td>
                        <asp:LinkButton ID="lnkAdminUserPage" runat="server" Font-Names="Verdana" Font-Size="X-Small"
                            ForeColor="Black" OnClick="lnkAdminUserPage_Click">Back to Administer Users Page</asp:LinkButton></td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress runat="server" ID="GridViewProgress">
        <ProgressTemplate>
            <div class="GridViewProgress">
                <img align="absMiddle" src="Images/snake_transparent.gif" width="16" height="16" />&nbsp<span>Updating... Please
                    Wait.</span></div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
